/*
 *  $Id: ParticleInfo.cs 1142 2010-09-30 11:33:54Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008-2009 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System.Collections.Generic;

using AgateLib.DisplayLib;
using AgateLib.Geometry;

namespace Ragima.UI {
    /// <summary>
    /// Информация о частице: картинка, состояния рождения/жизни/смерти, траектория.
    /// </summary>
    public class ParticleInfo {
        private Surface _image;
        private List<ParticleState> _phases;

        public ParticleInfo(Surface image) {
            Image = image;
            _phases = new List<ParticleState>();
        }
        public ParticleInfo(Surface image, params ParticleState[] phases) : this(image) {
            _phases.AddRange(phases);
        }

        public Surface Image {
            get { return _image; }
            set {
                _image = value;
                _image.DisplayAlignment = OriginAlignment.Center;
                _image.RotationCenter = OriginAlignment.Center;
            }
        }

        public List<ParticleState> Phases {
            get { return _phases; }
        }

        public ParticleState First {
            get { return _phases.Count > 0 ? _phases[0] : null; }
        }

        public ParticleState Last {
            get { return _phases.Count > 0 ? _phases[_phases.Count - 1] : null; }
        }

        public void AddPhase(ParticleState phase) {
            _phases.Add(phase);
        }

        public void AddPhase(int morphTime, int lifeTime, Color color, double alpha) {
            AddPhase(morphTime, lifeTime, color, alpha, 1, 0, null);
        }
        public void AddPhase(int morphTime, int lifeTime, Color color, double alpha, double scale) {
            AddPhase(morphTime, lifeTime, color, alpha, scale, 0, null);
        }
        public void AddPhase(int morphTime, int lifeTime, Color color, double alpha, double scale, double angle) {
            AddPhase(morphTime, lifeTime, color, alpha, scale, angle, null);
        }
        public void AddPhase(int morphTime, int lifeTime, Color color, double alpha, double scale, double angle, IEnumerable<PointF> trajectory) {
            AddPhase(new ParticleState(morphTime, lifeTime, color, alpha, scale, angle, trajectory));
        }
    }
}
